home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / info / gpc.i15 < prev    next >
Encoding:
GNU Info File  |  2001-02-09  |  50.0 KB  |  3,009 lines

  1. This is gpc.info, produced by makeinfo version 4.0 from gpc.texi.
  2.  
  3. INFO-DIR-SECTION GNU programming tools
  4. START-INFO-DIR-ENTRY
  5. * GPC: (gpc).                   The GNU Pascal Compiler.
  6. END-INFO-DIR-ENTRY
  7. INFO-DIR-SECTION Individual utilities
  8. START-INFO-DIR-ENTRY
  9. * GPC: (gpc)Invoking GPC.       The GNU Pascal Compiler.
  10. END-INFO-DIR-ENTRY
  11.  
  12.    This file documents the GNU Pascal Compiler.
  13.  
  14.    Copyright (C) 1988, 1996-2001 Free Software Foundation, Inc.
  15.  
  16.    Permission is granted to make and distribute verbatim copies of this
  17. manual provided the copyright notice and this permission notice are
  18. preserved on all copies.
  19.  
  20.    Permission is granted to copy and distribute modified versions of
  21. this manual under the conditions for verbatim copying, provided also
  22. that the sections entitled "GNU General Public License", "The GNU
  23. Project", "The GNU Manifesto" and "Funding for Free Software" are
  24. included exactly as in the original, and provided that the entire
  25. resulting derived work is distributed under the terms of a permission
  26. notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that the sections entitled "GNU General Public
  31. License", "The GNU Project", "The GNU Manifesto" and "Funding for Free
  32. Software" and this permission notice, may be included in translations
  33. approved by the Free Software Foundation instead of in the original
  34. English.
  35.  
  36. 
  37. File: gpc.info,  Node: Move,  Next: MoveLeft,  Prev: module,  Up: Reference
  38.  
  39. Move
  40. ====
  41.  
  42.    (Under construction.)
  43.  
  44. Synopsis
  45. --------
  46.  
  47.      procedure Move (const Source; var Dest; Count: Integer);
  48.  
  49. Description
  50. -----------
  51.  
  52. Conforming to
  53. -------------
  54.  
  55. Example
  56. -------
  57.  
  58. See also
  59. --------
  60.  
  61. 
  62. File: gpc.info,  Node: MoveLeft,  Next: MoveRight,  Prev: Move,  Up: Reference
  63.  
  64. MoveLeft
  65. ========
  66.  
  67.    (Under construction.)
  68.  
  69. Synopsis
  70. --------
  71.  
  72.      procedure MoveLeft (const Source; var Dest; Count: Integer);
  73.  
  74. Description
  75. -----------
  76.  
  77. Conforming to
  78. -------------
  79.  
  80. Example
  81. -------
  82.  
  83. See also
  84. --------
  85.  
  86. 
  87. File: gpc.info,  Node: MoveRight,  Next: Name,  Prev: MoveLeft,  Up: Reference
  88.  
  89. MoveRight
  90. =========
  91.  
  92.    (Under construction.)
  93.  
  94. Synopsis
  95. --------
  96.  
  97.      procedure MoveRight (const Source; var Dest; count: Integer);
  98.  
  99. Description
  100. -----------
  101.  
  102. Conforming to
  103. -------------
  104.  
  105. Example
  106. -------
  107.  
  108. See also
  109. --------
  110.  
  111. 
  112. File: gpc.info,  Node: Name,  Next: NE,  Prev: MoveRight,  Up: Reference
  113.  
  114. Name
  115. ====
  116.  
  117.    (Under construction.)
  118.  
  119. Synopsis
  120. --------
  121.  
  122. Description
  123. -----------
  124.  
  125. Conforming to
  126. -------------
  127.  
  128. Example
  129. -------
  130.  
  131. See also
  132. --------
  133.  
  134. 
  135. File: gpc.info,  Node: NE,  Next: near,  Prev: Name,  Up: Reference
  136.  
  137. NE
  138. ==
  139.  
  140.    (Under construction.)
  141.  
  142. Synopsis
  143. --------
  144.  
  145.      function NE (S1, S2: String): Boolean;
  146.  
  147. Description
  148. -----------
  149.  
  150. Conforming to
  151. -------------
  152.  
  153. Example
  154. -------
  155.  
  156. See also
  157. --------
  158.  
  159. 
  160. File: gpc.info,  Node: near,  Next: New,  Prev: NE,  Up: Reference
  161.  
  162. near
  163. ====
  164.  
  165. Synopsis
  166. --------
  167.  
  168. Description
  169. -----------
  170.  
  171.    The `near' directive can be appended to a procedure or function
  172. heading but is ignored by GPC. It is there for Borland compatibility,
  173. only. (Since the GNU compilers provide a flat memory model, the
  174. distinction between `near' and `near' pointers is void.)
  175.  
  176. Conforming to
  177. -------------
  178.  
  179.    `near' is a Borland Pascal extension.
  180.  
  181. Example
  182. -------
  183.  
  184.      program NearDemo;
  185.      
  186.      var
  187.        p: procedure;
  188.      
  189.      {$W-}  { Don't warn about the uselessness of `near' }
  190.      
  191.      procedure Foo; near;  { `near' has no effect in GPC }
  192.      begin
  193.        WriteLn ('Foo')
  194.      end;
  195.      
  196.      begin
  197.        p := Foo;  { Works, despite the `near'. }
  198.        p
  199.      end.
  200.  
  201. See also
  202. --------
  203.  
  204.    *Note far::.
  205.  
  206. 
  207. File: gpc.info,  Node: New,  Next: NewCString,  Prev: near,  Up: Reference
  208.  
  209. New
  210. ===
  211.  
  212.    (Under construction.)
  213.  
  214. Synopsis
  215. --------
  216.  
  217.      procedure New (var P: ANY POINTER);
  218.    or
  219.      procedure New (var P: POINTER TO A VARIANT RECORD; TAG FIELDS);
  220.    or
  221.      procedure New (var P: POINTER TO A SCHEMA; DISCRIMINANTS);
  222.    or
  223.      procedure New (var P: POINTER TO AN OBJECT; CONSTRUCTOR CALL);
  224.    or
  225.      function New (ANY POINTER TYPE): SAME TYPE;
  226.    or
  227.      function New (VARIANT RECORD POINTER TYPE;
  228.                    TAG FIELDS): SAME TYPE;
  229.    or
  230.      function New (SCHEMA POINTER TYPE;
  231.                    DISCRIMINANTS): SAME TYPE;
  232.    or
  233.      function New (OBJECT POINTER TYPE;
  234.                    CONSTRUCTOR CALL): SAME TYPE;
  235.  
  236. Description
  237. -----------
  238.  
  239. Conforming to
  240. -------------
  241.  
  242. Example
  243. -------
  244.  
  245. See also
  246. --------
  247.  
  248. 
  249. File: gpc.info,  Node: NewCString,  Next: nil,  Prev: New,  Up: Reference
  250.  
  251. NewCString
  252. ==========
  253.  
  254.    (Under construction.)
  255.  
  256. Synopsis
  257. --------
  258.  
  259.      function NewCString (const S: String): CString;
  260.  
  261. Description
  262. -----------
  263.  
  264. Conforming to
  265. -------------
  266.  
  267. Example
  268. -------
  269.  
  270. See also
  271. --------
  272.  
  273. 
  274. File: gpc.info,  Node: nil,  Next: not,  Prev: NewCString,  Up: Reference
  275.  
  276. nil
  277. ===
  278.  
  279. Synopsis
  280. --------
  281.  
  282.    `nil' is a predefined constant
  283.  
  284. Description
  285. -----------
  286.  
  287.    `nil' is a predefined pointer constant that indicates an unassigned
  288. pointer. "nil" stands for "not in list". _Every_ pointer type can be
  289. associated with this constant.
  290.  
  291. Conforming to
  292. -------------
  293.  
  294.    `nil' is defined in ISO-7185 Standard Pascal and supported by all
  295. known Pascal variants.
  296.  
  297. Example
  298. -------
  299.  
  300.      program NilDemo;
  301.      const
  302.        NodeNum = 10;
  303.      type
  304.        PNode = ^TNode;
  305.        TNode = record
  306.          Key: Integer;
  307.          Next: PNode
  308.        end;
  309.      var
  310.        Root, Node: PNode;
  311.        Foo: Integer;
  312.      begin
  313.        New (Root);
  314.        Root^.Key := 1;             { Set root key }
  315.        Node := Root;
  316.        for Foo := 2 to NodeNum do  { Create linked list with NODE_NUM nodes }
  317.          begin
  318.            New (Node^.Next);
  319.            Node := Node^.Next;
  320.            Node^.Key := Foo        { Set key }
  321.          end;
  322.        Node^.Next := nil;          { Mark end of linked list }
  323.        { Shorten list by removing its first element until list is empty }
  324.        while Root <> nil do
  325.          begin
  326.            Node := Root;
  327.            WriteLn ('Current key:', Root^.Key);
  328.            Root := Root^.Next;
  329.            Dispose (Node);
  330.            Node := nil             { Indicate old node is not assigned }
  331.          end
  332.      end.
  333.  
  334. See also
  335. --------
  336.  
  337.    *Note Assigned::, *Note Pointer::
  338.  
  339. 
  340. File: gpc.info,  Node: not,  Next: Null,  Prev: nil,  Up: Reference
  341.  
  342. not
  343. ===
  344.  
  345.    (Under construction.)
  346.  
  347. Synopsis
  348. --------
  349.  
  350.      operator not (b1, b2: Boolean) = Result: Boolean;
  351.    or
  352.      operator not (i1, i2: INTEGER TYPE) = Result: INTEGER TYPE;
  353.  
  354. Description
  355. -----------
  356.  
  357. Conforming to
  358. -------------
  359.  
  360. Example
  361. -------
  362.  
  363. See also
  364. --------
  365.  
  366. 
  367. File: gpc.info,  Node: Null,  Next: object,  Prev: not,  Up: Reference
  368.  
  369. Null
  370. ====
  371.  
  372. Synopsis
  373. --------
  374.  
  375.      var
  376.        Null: Void absolute 0;
  377.  
  378. Description
  379. -----------
  380.  
  381.    `Null' is a predefined variable at address `nil'.  `Null' can be
  382. passed as a "void" argument to a procedure, function or operator
  383. expecting a "var" parameter. _Note_: Make sure they can handle this
  384. case, otherwise this is likely to cause an exception and the program
  385. will be terminated. Since `Null' is an L-value, it can be taken as
  386. "nil-reference".
  387.  
  388. Conforming to
  389. -------------
  390.  
  391.    `Null' is a Borland Delphi extension.
  392.  
  393. Example
  394. -------
  395.  
  396.      program NullDemo;
  397.      type
  398.        PString = ^String;
  399.      var
  400.        Com1: String (25) = 'This is an amazing number';
  401.        Com2: String (25) = 'This is a boring number';
  402.      
  403.      procedure FooBar (Foo: Integer; var Comment: PString);
  404.      begin
  405.        if Odd (Foo) then
  406.          WriteLn ('FooBar:', Foo, ' is odd')
  407.         else
  408.          WriteLn ('FooBar:', Foo, ' is even');
  409.        if @Comment <> nil then
  410.          if not Odd(foo) then
  411.            Comment := @Com1
  412.          else
  413.            Comment := @Com2
  414.      end;
  415.      
  416.      var
  417.        S: String (25);
  418.        P: PString value @S;
  419.      
  420.      begin
  421.        { FooBar allows you to leave out variables
  422.          for any information you might not need }
  423.        FooBar (1, Null);
  424.        { But FooBar is flexible, after all }
  425.        FooBar (6, p);
  426.        WriteLn ('FooBar said about 6: `', P^, '''')
  427.      end.
  428.  
  429. See also
  430. --------
  431.  
  432.    *Note nil::
  433.  
  434. 
  435. File: gpc.info,  Node: object,  Next: Odd,  Prev: Null,  Up: Reference
  436.  
  437. object
  438. ======
  439.  
  440. Synopsis
  441. --------
  442.  
  443. Description
  444. -----------
  445.  
  446.    The keyword `object' is used to declare a new object type:
  447.  
  448.      type
  449.        foo = object
  450.          a: Integer;
  451.          constructor Init;
  452.          procedure Bar (x: Integer); virtual;
  453.        end;
  454.  
  455.    (For a longer example, see *Note OOP::.)
  456.  
  457. Conforming to
  458. -------------
  459.  
  460.    GNU Pascal follows the Borland Pascal 7.0 object model.
  461.  
  462.    ISO Pascal does not support Object-orientated programming. There is
  463. an ANSI draft for an "Object Pascal" language which is not yet
  464. supported by GPC, but planned. The Delphi language, also called "Object
  465. Pascal" by Borland, is currently not supported by GPC either.
  466.  
  467. Example
  468. -------
  469.  
  470. See also
  471. --------
  472.  
  473.    *Note OOP::, *Note record::.
  474.  
  475. 
  476. File: gpc.info,  Node: Odd,  Next: of,  Prev: object,  Up: Reference
  477.  
  478. Odd
  479. ===
  480.  
  481. Synopsis
  482. --------
  483.  
  484.      function Odd (i: Integer): Boolean;
  485.  
  486. Description
  487. -----------
  488.  
  489.    `Odd' checks the parity of its argument `i'. It returns `True' if
  490. the argument is odd, `False' if it is even.
  491.  
  492. Conforming to
  493. -------------
  494.  
  495.    `Odd' is defined in ISO-7185 Standard Pascal and supported by all
  496. known Pascal variants.
  497.  
  498. Example
  499. -------
  500.  
  501.      program OddDemo;
  502.      var
  503.        Foo: Integer;
  504.      begin
  505.        Write ('Please enter an odd number: ');
  506.        ReadLn (Foo);
  507.        if not Odd (Foo) then
  508.          WriteLn ('Odd''s not even! Something''s odd out there ...')
  509.        else
  510.          WriteLn (Foo, ' is pretty odd.')
  511.      end.
  512.  
  513. See also
  514. --------
  515.  
  516. 
  517. File: gpc.info,  Node: of,  Next: only,  Prev: Odd,  Up: Reference
  518.  
  519. of
  520. ==
  521.  
  522.    (Under construction.)
  523.  
  524. Synopsis
  525. --------
  526.  
  527. Description
  528. -----------
  529.  
  530. Conforming to
  531. -------------
  532.  
  533. Example
  534. -------
  535.  
  536. See also
  537. --------
  538.  
  539. 
  540. File: gpc.info,  Node: only,  Next: operator,  Prev: of,  Up: Reference
  541.  
  542. only
  543. ====
  544.  
  545.    (Under construction.)
  546.  
  547. Synopsis
  548. --------
  549.  
  550. Description
  551. -----------
  552.  
  553. Conforming to
  554. -------------
  555.  
  556. Example
  557. -------
  558.  
  559. See also
  560. --------
  561.  
  562. 
  563. File: gpc.info,  Node: operator,  Next: or,  Prev: only,  Up: Reference
  564.  
  565. operator
  566. ========
  567.  
  568.    (Under construction.)
  569.  
  570. Synopsis
  571. --------
  572.  
  573. Description
  574. -----------
  575.  
  576. Conforming to
  577. -------------
  578.  
  579. Example
  580. -------
  581.  
  582. See also
  583. --------
  584.  
  585. 
  586. File: gpc.info,  Node: or,  Next: or else,  Prev: operator,  Up: Reference
  587.  
  588. or
  589. ==
  590.  
  591. Synopsis
  592. --------
  593.  
  594.      operator or (operand1, operand2: Boolean) = Result: Boolean;
  595.    or
  596.      operator or (operand1, operand2: INTEGER TYPE) = Result: INTEGER TYPE;
  597.    or
  598.      procedure or (var operand1: INTEGER TYPE; operand2: INTEGER TYPE);
  599.  
  600. Description
  601. -----------
  602.  
  603.    In GNU Pascal, `or' has three built-in meanings:
  604.  
  605.   1. Logical "or" between two `Boolean'-type expressions.  The result
  606.      of the operation is of `Boolean' type.
  607.  
  608.      By default, `or' acts as a short-circuit operator in GPC:  If the
  609.      first operand is `True', the second operand is not evaluated
  610.      because the result is already known to be `True'.  You can change
  611.      this to complete evaluation using the `--no-short-circuit'
  612.      command-line option or the `{$B+}' compiler directive.
  613.  
  614.   2. Bitwise "or" between two integer-type expressions.  The result is
  615.      of the common integer type of both expressions.
  616.  
  617.   3. Use as a "procedure":  `operand1' is "or"ed bitwise with
  618.      `operand2'; the result is stored in `operand1'.
  619.  
  620.  
  621. Conforming to
  622. -------------
  623.  
  624.    The logical `or' operator is defined in ISO-7185 Standard Pascal.
  625.  
  626.    According to ISO, you cannot rely on `or' being a short-circuit
  627. operator. On the other hand, GPC's default behaviour does _not_
  628. contradict the ISO standard. (See *Note or_else::.) However, since it
  629. seems to be a de-facto standard among ISO Pascal compilers to evaluate
  630. both operands of `or', GPC switches to `--no-short-circuit' mode if one
  631. of the language dialect options selecting ISO Pascal, for instance
  632. `--extended-pascal', is given. Use `--short-circuit' to override.
  633.  
  634.    Use of `or' as a bitwise operator for integers is a Borland Pascal
  635. extension.
  636.  
  637.    Use of `or' as a "procedure" is a GNU Pascal extension.
  638.  
  639. Example
  640. -------
  641.  
  642.      program OrDemo;
  643.      var
  644.        a, b, c: Integer;
  645.      begin
  646.        if (a = 0) or (b = 0) then  { logical `or' }
  647.          c := 1
  648.        else if a or b = 0 then  { bitwise `or' }
  649.          c := 2
  650.        else
  651.          or (c, a)  { same as `c := c or a' }
  652.      end.
  653.  
  654.    Note the difference between the logical `or' and the bitwise `or':
  655. When `a' is 2 and `b' is 4, then `a or b' is 6. *Beware:* `a or b = 0'
  656. happens to mean the same as `(a = 0) and (b = 0)'. (Note the `and'!)
  657.  
  658.    Since bitwise `or' has a higher priority than the `=' operator,
  659. parentheses are needed in `if (a = 0) or (b = 0)' because otherwise `0
  660. or b' would be calculated first, and the remainder would cause a parse
  661. error.
  662.  
  663. See also
  664. --------
  665.  
  666.    *Note and::, *Note xor::, *Note Operators::.
  667.  
  668. 
  669. File: gpc.info,  Node: or else,  Next: Ord,  Prev: or,  Up: Reference
  670.  
  671. or else
  672. =======
  673.  
  674. Synopsis
  675. --------
  676.  
  677.      { `or else' is built in. A user-defined operator cannot consist of
  678.         two words. }
  679.      operator or else (operand1, operand2: Boolean) = Result: Boolean;
  680.  
  681. Description
  682. -----------
  683.  
  684.    `or else' is an alias for the short-circuit logical operator
  685. `or_else'.
  686.  
  687. Conforming to
  688. -------------
  689.  
  690.    While `or_else' is defined in ISO-10206 Extended Pascal, `or else'
  691. is a GNU Extension.
  692.  
  693. Example
  694. -------
  695.  
  696.      program OrElseDemo;
  697.      var
  698.        a: Integer;
  699.      begin
  700.        ReadLn (a);
  701.        if (a = 0) or else (100 div a > 42) then  { This is safe. }
  702.          WriteLn ('100 div a > 42')
  703.      end.
  704.  
  705. See also
  706. --------
  707.  
  708.    *Note or_else::, *Note or::, *Note and then::.
  709.  
  710. 
  711. File: gpc.info,  Node: Ord,  Next: or_else,  Prev: or else,  Up: Reference
  712.  
  713. Ord
  714. ===
  715.  
  716.    (Under construction.)
  717.  
  718. Synopsis
  719. --------
  720.  
  721.      function Ord (Ch: Char): Integer;
  722.  
  723. Description
  724. -----------
  725.  
  726. Conforming to
  727. -------------
  728.  
  729.    `Ord' is defined in ISO-7185 Standard Pascal and supported by all
  730. known Pascal variants.
  731.  
  732. Example
  733. -------
  734.  
  735. See also
  736. --------
  737.  
  738. 
  739. File: gpc.info,  Node: or_else,  Next: otherwise,  Prev: Ord,  Up: Reference
  740.  
  741. or_else
  742. =======
  743.  
  744. Synopsis
  745. --------
  746.  
  747.      operator or_else (operand1, operand2: Boolean) = Result: Boolean;
  748.  
  749. Description
  750. -----------
  751.  
  752.    The `or_else' short-circuit logical operator performs the same
  753. operation as the logical operator `or'. But while the ISO standard does
  754. not specify anything about the evaluation of the operands of `or' -
  755. they may be evaluated in any order, or not at all - `or_else' has a
  756. well-defined behaviour: It evaluates the first operand. If the result
  757. is `True', `or_else' returns `True' without evaluating the second
  758. operand. If it is `False', the second operand is evaluated and returned.
  759.  
  760.    GPC by default treats `or' and `or_else' exactly the same.  If you
  761. want, for some reason, to have both operands of `or' evaluated
  762. completely, you must assign both to temporary variables and then use
  763. `or' - or `or_else', it does not matter.
  764.  
  765. Conforming to
  766. -------------
  767.  
  768.    `or_else' is an ISO-10206 Extended Pascal extension.
  769.  
  770.    Some people think that the ISO standard requires both operands of
  771. `or' to be evaluated. This is false. What the ISO standard _does_ say
  772. is that you cannot rely on a certain order of evaluation of the
  773. operands of `or'; in particular things like the following program can
  774. crash according to ISO Pascal, although they cannot crash when compiled
  775. with GNU Pascal running in default mode.
  776.  
  777.      program OrBug;
  778.      var
  779.        a: Integer;
  780.      begin
  781.        ReadLn (a);
  782.        if (a = 0) or (100 div a > 42) then  { This is NOT safe! }
  783.          WriteLn ('You''re lucky. But the test could have crashed...')
  784.      end.
  785.  
  786. Example
  787. -------
  788.  
  789.      program Or_ElseDemo;
  790.      var
  791.        a: Integer;
  792.      begin
  793.        ReadLn (a);
  794.        if (a = 0) or_else (100 div a > 42) then  { This is safe. }
  795.          WriteLn ('100 div a > 42')
  796.      end.
  797.  
  798. See also
  799. --------
  800.  
  801.    *Note or else::, *Note or::, *Note and_then::.
  802.  
  803. 
  804. File: gpc.info,  Node: otherwise,  Next: Output,  Prev: or_else,  Up: Reference
  805.  
  806. otherwise
  807. =========
  808.  
  809.    (Under construction.)
  810.  
  811. Synopsis
  812. --------
  813.  
  814. Description
  815. -----------
  816.  
  817. Conforming to
  818. -------------
  819.  
  820. Example
  821. -------
  822.  
  823. See also
  824. --------
  825.  
  826. 
  827. File: gpc.info,  Node: Output,  Next: Override,  Prev: otherwise,  Up: Reference
  828.  
  829. Output
  830. ======
  831.  
  832.    (Under construction.)
  833.  
  834. Synopsis
  835. --------
  836.  
  837.      var
  838.        Output: Text;
  839.  
  840. Description
  841. -----------
  842.  
  843. Conforming to
  844. -------------
  845.  
  846. Example
  847. -------
  848.  
  849. See also
  850. --------
  851.  
  852. 
  853. File: gpc.info,  Node: Override,  Next: Pack,  Prev: Output,  Up: Reference
  854.  
  855. Override
  856. ========
  857.  
  858.    (Under construction.)
  859.  
  860. Synopsis
  861. --------
  862.  
  863. Description
  864. -----------
  865.  
  866. Conforming to
  867. -------------
  868.  
  869. Example
  870. -------
  871.  
  872. See also
  873. --------
  874.  
  875. 
  876. File: gpc.info,  Node: Pack,  Next: packed,  Prev: Override,  Up: Reference
  877.  
  878. Pack
  879. ====
  880.  
  881.    (Under construction.)
  882.  
  883. Synopsis
  884. --------
  885.  
  886. Description
  887. -----------
  888.  
  889.      procedure Pack (Source: UNPACKED ARRAY;
  890.                      FirstElement: INDEX TYPE;
  891.                      var Dest: PACKED ARRAY);
  892.  
  893. Conforming to
  894. -------------
  895.  
  896. Example
  897. -------
  898.  
  899. See also
  900. --------
  901.  
  902. 
  903. File: gpc.info,  Node: packed,  Next: Page,  Prev: Pack,  Up: Reference
  904.  
  905. packed
  906. ======
  907.  
  908. Synopsis
  909. --------
  910.  
  911. Description
  912. -----------
  913.  
  914.    `packed' is a reserved word. According to ISO-7185 Standard Pascal
  915. it can precede `array' and `record' type definitions to indicate that
  916. memory usage should be minimized for variables of this type, possibly
  917. at the expense of loss of speed.
  918.  
  919.    As a GNU extension, `packed' can also be applied to *Note Subrange
  920. Types::.
  921.  
  922. Conforming to
  923. -------------
  924.  
  925.    The reserved word `packed' is defined in ISO-7185 Standard Pascal.
  926.  
  927.    According to ISO standard, only _packed_ arrays of char with lower
  928. bound 1 qualify as strings of fixed length. GNU Pascal neither requires
  929. `packed' nor the lower bound of 1 here.
  930.  
  931. Example
  932. -------
  933.  
  934.      program PackedDemo;
  935.      
  936.      type
  937.        MonthInt = packed 1 .. 12;  { needs one byte   }
  938.        FastMonthInt = 1 .. 12;     { needs four bytes }
  939.      
  940.        FixString10 = packed array [1 .. 10] of Char;
  941.        FoxyString10 = array [0 .. 9] of Char;
  942.      
  943.        Flags = packed array [1 .. 32] of Boolean;  { needs four Bytes }
  944.      
  945.        DateRec = packed record
  946.          Day: 1 .. 31;       { five bits }
  947.          Month: MonthInt;    { four bits }
  948.          Year: Integer (15)  { 15 bits = -16384 .. 16383 }
  949.        end;
  950.      
  951.        Dates = array [1 .. 1000] of DateRec;
  952.      
  953.      var
  954.        S: FixString10;
  955.        T: FoxyString10;
  956.      
  957.      begin
  958.        S := 'Hello!';   { blank padded }
  959.        WriteLn (S);
  960.      
  961.        T := 'GNU Pascal';  { GPC extension: this also works. }
  962.        WriteLn (T)
  963.      end.
  964.  
  965.    `DateRec' has 24 bits = 3 bytes in total; `Dates' has 3000 bytes.
  966.  
  967. See also
  968. --------
  969.  
  970.    *Note Pack::, *Note Unpack::, *Note SizeOf::, *Note AlignOf::, *Note
  971. BitSizeOf::.
  972.  
  973. 
  974. File: gpc.info,  Node: Page,  Next: PAnsiChar,  Prev: packed,  Up: Reference
  975.  
  976. Page
  977. ====
  978.  
  979.    (Under construction.)
  980.  
  981. Synopsis
  982. --------
  983.  
  984.      procedure Page (var F: Text);
  985.    or
  986.      procedure Page;
  987.  
  988. Description
  989. -----------
  990.  
  991. Conforming to
  992. -------------
  993.  
  994. Example
  995. -------
  996.  
  997. See also
  998. --------
  999.  
  1000. 
  1001. File: gpc.info,  Node: PAnsiChar,  Next: ParamCount,  Prev: Page,  Up: Reference
  1002.  
  1003. PAnsiChar
  1004. =========
  1005.  
  1006.    (Under construction.)
  1007.  
  1008. Synopsis
  1009. --------
  1010.  
  1011.      type
  1012.        PAnsiChar = ^AnsiChar;
  1013.  
  1014. Description
  1015. -----------
  1016.  
  1017. Conforming to
  1018. -------------
  1019.  
  1020. Example
  1021. -------
  1022.  
  1023.      program PAnsiCharDemo;
  1024.      var
  1025.        s: PAnsiChar;
  1026.      begin
  1027.        s := 'Hello, world!';
  1028.        {$X+}
  1029.        WriteLn (s)
  1030.      end.
  1031.  
  1032. See also
  1033. --------
  1034.  
  1035. 
  1036. File: gpc.info,  Node: ParamCount,  Next: ParamStr,  Prev: PAnsiChar,  Up: Reference
  1037.  
  1038. ParamCount
  1039. ==========
  1040.  
  1041. Synopsis
  1042. --------
  1043.  
  1044.      function ParamCount: Integer;
  1045.  
  1046. Description
  1047. -----------
  1048.  
  1049.    `ParamCount' returns the number of command-line arguments given to
  1050. the program.  `ParamCount' returns 0 if no arguments have been given to
  1051. the program; the name of the program as an implicit argument is not
  1052. counted.
  1053.  
  1054. Conforming to
  1055. -------------
  1056.  
  1057.    `ParamCount' is a Borland Pascal extension.
  1058.  
  1059. Example
  1060. -------
  1061.  
  1062.      program ParamCountDemo;
  1063.      
  1064.      var
  1065.        i: Integer;
  1066.      
  1067.      begin
  1068.        WriteLn ('You have invoked this program with ',
  1069.                 ParamCount, ' arguments.');
  1070.        WriteLn ('These are:');
  1071.        for i := 1 to ParamCount do
  1072.          WriteLn (ParamStr (i))
  1073.      end.
  1074.  
  1075. See also
  1076. --------
  1077.  
  1078.    *Note ParamStr::.
  1079.  
  1080. 
  1081. File: gpc.info,  Node: ParamStr,  Next: PChar,  Prev: ParamCount,  Up: Reference
  1082.  
  1083. ParamStr
  1084. ========
  1085.  
  1086.    (Under construction.)
  1087.  
  1088. Synopsis
  1089. --------
  1090.  
  1091.      function ParamStr (ParmNumber: Integer): String;
  1092.  
  1093. Description
  1094. -----------
  1095.  
  1096.    *Note:* If you are using the Dos (DJGPP) or MS-Windows (mingw32)
  1097. version of GPC and are getting unexpected results from `ParamStr',
  1098. please see the section "Command-line Arguments Handling in DJGPP" of
  1099. the DJGPP FAQ list.
  1100.  
  1101. Conforming to
  1102. -------------
  1103.  
  1104. Example
  1105. -------
  1106.  
  1107. See also
  1108. --------
  1109.  
  1110. 
  1111. File: gpc.info,  Node: PChar,  Next: Pi,  Prev: ParamStr,  Up: Reference
  1112.  
  1113. PChar
  1114. =====
  1115.  
  1116.    (Under construction.)
  1117.  
  1118. Synopsis
  1119. --------
  1120.  
  1121.      type
  1122.        PChar = ^Char;
  1123.    or
  1124.      type
  1125.        PChar = CString;
  1126.  
  1127. Description
  1128. -----------
  1129.  
  1130. Conforming to
  1131. -------------
  1132.  
  1133. Example
  1134. -------
  1135.  
  1136.      program PCharDemo;
  1137.      var
  1138.        s: PChar;
  1139.      begin
  1140.        s := 'Hello, world!';
  1141.        {$X+}
  1142.        WriteLn (s)
  1143.      end.
  1144.  
  1145. See also
  1146. --------
  1147.  
  1148. 
  1149. File: gpc.info,  Node: Pi,  Next: Pointer,  Prev: PChar,  Up: Reference
  1150.  
  1151. Pi
  1152. ==
  1153.  
  1154.    (Under construction.)
  1155.  
  1156. Synopsis
  1157. --------
  1158.  
  1159. Description
  1160. -----------
  1161.  
  1162. Conforming to
  1163. -------------
  1164.  
  1165. Example
  1166. -------
  1167.  
  1168. See also
  1169. --------
  1170.  
  1171. 
  1172. File: gpc.info,  Node: Pointer,  Next: Polar,  Prev: Pi,  Up: Reference
  1173.  
  1174. Pointer
  1175. =======
  1176.  
  1177.    (Under construction.)
  1178.  
  1179. Synopsis
  1180. --------
  1181.  
  1182.      type
  1183.        Pointer  { built-in type }
  1184.  
  1185. Description
  1186. -----------
  1187.  
  1188. Conforming to
  1189. -------------
  1190.  
  1191. Example
  1192. -------
  1193.  
  1194.      program PointerDemo;
  1195.      var
  1196.        a: Integer;
  1197.        b: Boolean;
  1198.        p: Pointer;
  1199.      begin
  1200.        p := nil;
  1201.        p := @a;
  1202.        p := @b
  1203.      end.
  1204.  
  1205. See also
  1206. --------
  1207.  
  1208. 
  1209. File: gpc.info,  Node: Polar,  Next: Pos,  Prev: Pointer,  Up: Reference
  1210.  
  1211. Polar
  1212. =====
  1213.  
  1214.    (Under construction.)
  1215.  
  1216. Synopsis
  1217. --------
  1218.  
  1219.      function Polar (rho, phi: Real): Complex;
  1220.  
  1221. Description
  1222. -----------
  1223.  
  1224. Conforming to
  1225. -------------
  1226.  
  1227. Example
  1228. -------
  1229.  
  1230. See also
  1231. --------
  1232.  
  1233. 
  1234. File: gpc.info,  Node: Pos,  Next: Position,  Prev: Polar,  Up: Reference
  1235.  
  1236. Pos
  1237. ===
  1238.  
  1239.    (Under construction.)
  1240.  
  1241. Synopsis
  1242. --------
  1243.  
  1244.      function Pos (SearchPattern, Source: String): Integer;
  1245.  
  1246. Description
  1247. -----------
  1248.  
  1249. Conforming to
  1250. -------------
  1251.  
  1252. Example
  1253. -------
  1254.  
  1255. See also
  1256. --------
  1257.  
  1258. 
  1259. File: gpc.info,  Node: Position,  Next: pow,  Prev: Pos,  Up: Reference
  1260.  
  1261. Position
  1262. ========
  1263.  
  1264.    (Under construction.)
  1265.  
  1266. Synopsis
  1267. --------
  1268.  
  1269.      function Position (var F: TYPED FILE);
  1270.  
  1271. Description
  1272. -----------
  1273.  
  1274. Conforming to
  1275. -------------
  1276.  
  1277. Example
  1278. -------
  1279.  
  1280. See also
  1281. --------
  1282.  
  1283. 
  1284. File: gpc.info,  Node: pow,  Next: Pred,  Prev: Position,  Up: Reference
  1285.  
  1286. pow
  1287. ===
  1288.  
  1289.    (Under construction.)
  1290.  
  1291. Synopsis
  1292. --------
  1293.  
  1294.      operator pow (base: Real; exponent: Integer) = power: Real;
  1295.    or
  1296.      operator pow (base: Complex; exponent: Integer) = power: Complex;
  1297.  
  1298. Description
  1299. -----------
  1300.  
  1301. Conforming to
  1302. -------------
  1303.  
  1304. Example
  1305. -------
  1306.  
  1307. See also
  1308. --------
  1309.  
  1310. 
  1311. File: gpc.info,  Node: Pred,  Next: private,  Prev: pow,  Up: Reference
  1312.  
  1313. Pred
  1314. ====
  1315.  
  1316. Synopsis
  1317. --------
  1318.  
  1319.      function Pred (i: ORDINAL TYPE): ORDINAL TYPE;
  1320.    or
  1321.      function Pred (i: ORDINAL TYPE; j: Integer): ORDINAL TYPE;
  1322.  
  1323.    or, with extended syntax (`--extended-syntax' or `{$X+}'),
  1324.  
  1325.      function Pred (p: POINTER TYPE): POINTER TYPE;
  1326.    or
  1327.      function Pred (p: POINTER TYPE; j: Integer): POINTER TYPE;
  1328.  
  1329. Description
  1330. -----------
  1331.  
  1332.    Returns the predecessor of the ORDINAL TYPE value `i', or, if the
  1333. second argument `j' is given, its `j'th predecessor.  For integer
  1334. values `i', this is `i - 1' (or `i - j').  (No, `Pred' does _not_ work
  1335. faster than plain subtraction.  Both are optimized to a single machine
  1336. instruction or even expanded by the compiler, if possible.)
  1337.  
  1338.    If extended syntax is on, the argument may also be a pointer value.
  1339. In this case, the address is decremented by the size of the variable
  1340. pointed to, or, if `j' is given, by `j' times the size of the variable
  1341. pointed to.  If `p' points to an element of an array, the returned
  1342. pointer will point to the (`j'th) previous element of the array.
  1343.  
  1344. Conforming to
  1345. -------------
  1346.  
  1347.    The `Pred' function is defined in ISO-7185 Standard Pascal.  The
  1348. optional second parameter is defined in ISO-10206 Extended Pascal.
  1349. Application of `Pred' to pointers is defined in Borland Pascal.  The
  1350. combination of the second argument with application to pointers is a
  1351. GNU extension.
  1352.  
  1353. Example
  1354. -------
  1355.  
  1356.      program PredDemo;
  1357.      
  1358.      type
  1359.        Metasyntactical = (foo, bar, baz);
  1360.      
  1361.      var
  1362.        m: Metasyntactical;
  1363.        c: Char;
  1364.        a: array [1 .. 7] of Integer;
  1365.        p: ^Integer;
  1366.      
  1367.      begin
  1368.        m := Pred (bar);     { foo }
  1369.        c := Pred ('Z', 2);  { 'X' }
  1370.        a [1] := 42;
  1371.        a [4] := Pred (a [1]);     { 41 }
  1372.        a [5] := Pred (a [4], 3);  { 38 }
  1373.        {$X+}
  1374.        p := @a [5];
  1375.        p := Pred (p);     { now p points to a [4] }
  1376.        p := Pred (p, 3);  { now p points to a [1] }
  1377.      end.
  1378.  
  1379. See also
  1380. --------
  1381.  
  1382.    *Note Succ::, *Note Dec::, *Note Pointer Arithmetics::.
  1383.  
  1384. 
  1385. File: gpc.info,  Node: private,  Next: procedure,  Prev: Pred,  Up: Reference
  1386.  
  1387. private
  1388. =======
  1389.  
  1390.    (Under construction.)
  1391.  
  1392. Synopsis
  1393. --------
  1394.  
  1395. Description
  1396. -----------
  1397.  
  1398.    GPC currently accepts but ignores the `private' directive in object
  1399. type declarations.
  1400.  
  1401. Conforming to
  1402. -------------
  1403.  
  1404. Example
  1405. -------
  1406.  
  1407. See also
  1408. --------
  1409.  
  1410.    *Note protected::, *Note public::, *Note published::.
  1411.  
  1412. 
  1413. File: gpc.info,  Node: procedure,  Next: program,  Prev: private,  Up: Reference
  1414.  
  1415. procedure
  1416. =========
  1417.  
  1418.    (Under construction.)
  1419.  
  1420. Synopsis
  1421. --------
  1422.  
  1423. Description
  1424. -----------
  1425.  
  1426. Conforming to
  1427. -------------
  1428.  
  1429. Example
  1430. -------
  1431.  
  1432. See also
  1433. --------
  1434.  
  1435. 
  1436. File: gpc.info,  Node: program,  Next: property,  Prev: procedure,  Up: Reference
  1437.  
  1438. program
  1439. =======
  1440.  
  1441.    (Under construction.)
  1442.  
  1443. Synopsis
  1444. --------
  1445.  
  1446. Description
  1447. -----------
  1448.  
  1449. Conforming to
  1450. -------------
  1451.  
  1452. Example
  1453. -------
  1454.  
  1455. See also
  1456. --------
  1457.  
  1458. 
  1459. File: gpc.info,  Node: property,  Next: protected,  Prev: program,  Up: Reference
  1460.  
  1461. property
  1462. ========
  1463.  
  1464.    Not yet implemented.
  1465.  
  1466. Synopsis
  1467. --------
  1468.  
  1469. Description
  1470. -----------
  1471.  
  1472. Conforming to
  1473. -------------
  1474.  
  1475. Example
  1476. -------
  1477.  
  1478. See also
  1479. --------
  1480.  
  1481. 
  1482. File: gpc.info,  Node: protected,  Next: PtrCard,  Prev: property,  Up: Reference
  1483.  
  1484. protected
  1485. =========
  1486.  
  1487.    (Under construction.)
  1488.  
  1489. Synopsis
  1490. --------
  1491.  
  1492. Description
  1493. -----------
  1494.  
  1495.    The Extended Pascal meaning of `protected' is supported by GPC.
  1496.  
  1497.    GPC currently accepts but ignores the `protected' directive in
  1498. object type declarations.
  1499.  
  1500. Conforming to
  1501. -------------
  1502.  
  1503.    Extended Pascal and Borland Pascal, but with different meanings.
  1504.  
  1505. Example
  1506. -------
  1507.  
  1508. See also
  1509. --------
  1510.  
  1511.    *Note const::, *Note import::, *Note private::, *Note public::,
  1512. *Note published::.
  1513.  
  1514. 
  1515. File: gpc.info,  Node: PtrCard,  Next: PtrDiffType,  Prev: protected,  Up: Reference
  1516.  
  1517. PtrCard
  1518. =======
  1519.  
  1520.    (Under construction.)
  1521.  
  1522. Synopsis
  1523. --------
  1524.  
  1525.      type
  1526.        PtrCard = Cardinal (BitSizeOf (Pointer));
  1527.  
  1528. Description
  1529. -----------
  1530.  
  1531. Conforming to
  1532. -------------
  1533.  
  1534. Example
  1535. -------
  1536.  
  1537.      program PtrCardDemo;
  1538.      var
  1539.        a: PtrCard;
  1540.        p: Pointer;
  1541.      begin
  1542.        New (p);
  1543.        a := PtrCard (p);
  1544.        Inc (a);
  1545.        p := Pointer (a)
  1546.      end.
  1547.  
  1548. See also
  1549. --------
  1550.  
  1551. 
  1552. File: gpc.info,  Node: PtrDiffType,  Next: PtrInt,  Prev: PtrCard,  Up: Reference
  1553.  
  1554. PtrDiffType
  1555. ===========
  1556.  
  1557.    (Under construction.)
  1558.  
  1559. Synopsis
  1560. --------
  1561.  
  1562.      type
  1563.        PtrDiffType  { built-in type }
  1564.  
  1565. Description
  1566. -----------
  1567.  
  1568. Conforming to
  1569. -------------
  1570.  
  1571. Example
  1572. -------
  1573.  
  1574.      program PtrDiffTypeDemo;
  1575.      var
  1576.        a: array [1 .. 10] of Integer;
  1577.        d: PtrDiffType;
  1578.        p, q: Pointer;
  1579.      begin
  1580.        p := @a [1];
  1581.        q := @a [4];
  1582.        {$X+}
  1583.        d := q - p
  1584.      end.
  1585.  
  1586. See also
  1587. --------
  1588.  
  1589. 
  1590. File: gpc.info,  Node: PtrInt,  Next: PtrWord,  Prev: PtrDiffType,  Up: Reference
  1591.  
  1592. PtrInt
  1593. ======
  1594.  
  1595.    (Under construction.)
  1596.  
  1597. Synopsis
  1598. --------
  1599.  
  1600.      type
  1601.        PtrCard = Integer (BitSizeOf (Pointer));
  1602.  
  1603. Description
  1604. -----------
  1605.  
  1606. Conforming to
  1607. -------------
  1608.  
  1609. Example
  1610. -------
  1611.  
  1612.      program PtrIntDemo;
  1613.      var
  1614.        a: PtrInt;
  1615.        p: Pointer;
  1616.      begin
  1617.        New (p);
  1618.        a := PtrInt (p);
  1619.        Inc (a);
  1620.        p := Pointer (a)
  1621.      end.
  1622.  
  1623. See also
  1624. --------
  1625.  
  1626. 
  1627. File: gpc.info,  Node: PtrWord,  Next: public,  Prev: PtrInt,  Up: Reference
  1628.  
  1629. PtrWord
  1630. =======
  1631.  
  1632.    (Under construction.)
  1633.  
  1634. Synopsis
  1635. --------
  1636.  
  1637.      type
  1638.        PtrWord = PtrCard;
  1639.  
  1640. Description
  1641. -----------
  1642.  
  1643. Conforming to
  1644. -------------
  1645.  
  1646. Example
  1647. -------
  1648.  
  1649.      program PtrWordDemo;
  1650.      var
  1651.        a: PtrWord;
  1652.        p: Pointer;
  1653.      begin
  1654.        New (p);
  1655.        a := PtrWord (p);
  1656.        Inc (a);
  1657.        p := Pointer (a)
  1658.      end.
  1659.  
  1660. See also
  1661. --------
  1662.  
  1663. 
  1664. File: gpc.info,  Node: public,  Next: published,  Prev: PtrWord,  Up: Reference
  1665.  
  1666. public
  1667. ======
  1668.  
  1669.    (Under construction.)
  1670.  
  1671. Synopsis
  1672. --------
  1673.  
  1674. Description
  1675. -----------
  1676.  
  1677.    GPC currently accepts but ignores the `public' directive in object
  1678. type declarations.
  1679.  
  1680. Conforming to
  1681. -------------
  1682.  
  1683. Example
  1684. -------
  1685.  
  1686. See also
  1687. --------
  1688.  
  1689.    *Note private::, *Note protected::, *Note published::.
  1690.  
  1691. 
  1692. File: gpc.info,  Node: published,  Next: Put,  Prev: public,  Up: Reference
  1693.  
  1694. published
  1695. =========
  1696.  
  1697.    (Under construction.)
  1698.  
  1699. Synopsis
  1700. --------
  1701.  
  1702. Description
  1703. -----------
  1704.  
  1705.    GPC currently accepts but ignores the `published' directive in
  1706. object type declarations.
  1707.  
  1708. Conforming to
  1709. -------------
  1710.  
  1711. Example
  1712. -------
  1713.  
  1714. See also
  1715. --------
  1716.  
  1717.    *Note private::, *Note protected::, *Note public::.
  1718.  
  1719. 
  1720. File: gpc.info,  Node: Put,  Next: qualified,  Prev: published,  Up: Reference
  1721.  
  1722. Put
  1723. ===
  1724.  
  1725.    (Under construction.)
  1726.  
  1727. Synopsis
  1728. --------
  1729.  
  1730.      procedure Put (var F: TYPED FILE);
  1731.  
  1732. Description
  1733. -----------
  1734.  
  1735. Conforming to
  1736. -------------
  1737.  
  1738. Example
  1739. -------
  1740.  
  1741. See also
  1742. --------
  1743.  
  1744. 
  1745. File: gpc.info,  Node: qualified,  Next: Random,  Prev: Put,  Up: Reference
  1746.  
  1747. qualified
  1748. =========
  1749.  
  1750.    (Under construction.)
  1751.  
  1752. Synopsis
  1753. --------
  1754.  
  1755. Description
  1756. -----------
  1757.  
  1758. Conforming to
  1759. -------------
  1760.  
  1761. Example
  1762. -------
  1763.  
  1764. See also
  1765. --------
  1766.  
  1767. 
  1768. File: gpc.info,  Node: Random,  Next: Randomize,  Prev: qualified,  Up: Reference
  1769.  
  1770. Random
  1771. ======
  1772.  
  1773.    (Under construction.)
  1774.  
  1775. Synopsis
  1776. --------
  1777.  
  1778. Description
  1779. -----------
  1780.  
  1781. Conforming to
  1782. -------------
  1783.  
  1784. Example
  1785. -------
  1786.  
  1787. See also
  1788. --------
  1789.  
  1790. 
  1791. File: gpc.info,  Node: Randomize,  Next: Re,  Prev: Random,  Up: Reference
  1792.  
  1793. Randomize
  1794. =========
  1795.  
  1796.    (Under construction.)
  1797.  
  1798. Synopsis
  1799. --------
  1800.  
  1801. Description
  1802. -----------
  1803.  
  1804. Conforming to
  1805. -------------
  1806.  
  1807. Example
  1808. -------
  1809.  
  1810. See also
  1811. --------
  1812.  
  1813. 
  1814. File: gpc.info,  Node: Re,  Next: Read,  Prev: Randomize,  Up: Reference
  1815.  
  1816. Re
  1817. ==
  1818.  
  1819. Synopsis
  1820. --------
  1821.  
  1822.      function Re (z: Complex): Real;
  1823.  
  1824. Description
  1825. -----------
  1826.  
  1827.    `Re' extracts the real part of the complex number `z'.
  1828.  
  1829. Conforming to
  1830. -------------
  1831.  
  1832.    `Re' is an ISO-10206 Extended Pascal extension.
  1833.  
  1834. Example
  1835. -------
  1836.  
  1837.      program ReDemo;
  1838.      var
  1839.        z: Complex;
  1840.      begin
  1841.        z := Cmplx (1, 2);
  1842.        WriteLn (Re (z) : 0 : 5)
  1843.      end.
  1844.  
  1845. See also
  1846. --------
  1847.  
  1848.    *Note Cmplx::, *Note Im::, *Note Arg::
  1849.  
  1850. 
  1851. File: gpc.info,  Node: Read,  Next: ReadLn,  Prev: Re,  Up: Reference
  1852.  
  1853. Read
  1854. ====
  1855.  
  1856.    (Under construction.)
  1857.  
  1858. Synopsis
  1859. --------
  1860.  
  1861.      procedure Read (var F: TYPED FILE; VARIABLE);
  1862.    or
  1863.      procedure Read (var F: Text; VARIABLES);
  1864.    or
  1865.      procedure Read (VARIABLES);
  1866.  
  1867. Description
  1868. -----------
  1869.  
  1870. Conforming to
  1871. -------------
  1872.  
  1873. Example
  1874. -------
  1875.  
  1876. See also
  1877. --------
  1878.  
  1879. 
  1880. File: gpc.info,  Node: ReadLn,  Next: ReadStr,  Prev: Read,  Up: Reference
  1881.  
  1882. ReadLn
  1883. ======
  1884.  
  1885.    (Under construction.)
  1886.  
  1887. Synopsis
  1888. --------
  1889.  
  1890.      procedure ReadLn (var F: Text; VARIABLES);
  1891.    or
  1892.      procedure ReadLn (VARIABLES);
  1893.  
  1894. Description
  1895. -----------
  1896.  
  1897. Conforming to
  1898. -------------
  1899.  
  1900. Example
  1901. -------
  1902.  
  1903. See also
  1904. --------
  1905.  
  1906. 
  1907. File: gpc.info,  Node: ReadStr,  Next: Real,  Prev: ReadLn,  Up: Reference
  1908.  
  1909. ReadStr
  1910. =======
  1911.  
  1912.    (Under construction.)
  1913.  
  1914. Synopsis
  1915. --------
  1916.  
  1917.      procedure ReadStr (const S: String; VARIABLES);
  1918.  
  1919. Description
  1920. -----------
  1921.  
  1922. Conforming to
  1923. -------------
  1924.  
  1925. Example
  1926. -------
  1927.  
  1928. See also
  1929. --------
  1930.  
  1931. 
  1932. File: gpc.info,  Node: Real,  Next: record,  Prev: ReadStr,  Up: Reference
  1933.  
  1934. Real
  1935. ====
  1936.  
  1937.    (Under construction.)
  1938.  
  1939. Synopsis
  1940. --------
  1941.  
  1942.      type
  1943.        Real  { built-in type }
  1944.  
  1945. Description
  1946. -----------
  1947.  
  1948. Conforming to
  1949. -------------
  1950.  
  1951. Example
  1952. -------
  1953.  
  1954.      program RealDemo;
  1955.      var
  1956.        a: Real;
  1957.      begin
  1958.        a := 42;
  1959.        WriteLn (a)
  1960.      end.
  1961.  
  1962. See also
  1963. --------
  1964.  
  1965. 
  1966. File: gpc.info,  Node: record,  Next: register,  Prev: Real,  Up: Reference
  1967.  
  1968. record
  1969. ======
  1970.  
  1971. Synopsis
  1972. --------
  1973.  
  1974.    In type definitions:
  1975.      RECORD TYPE IDENTIFIER = record
  1976.        FIELD IDENTIFIER : TYPE DEFINITION
  1977.        ...
  1978.        FIELD IDENTIFIER : TYPE DEFINITION
  1979.      end;
  1980.  
  1981.    or, with a variant part,
  1982.  
  1983.      RECORD TYPE IDENTIFIER = record
  1984.        FIELD IDENTIFIER : TYPE DEFINITION
  1985.        ...
  1986.        FIELD IDENTIFIER : TYPE DEFINITION
  1987.        case bar: VARIANT TYPE of
  1988.          SELECTOR: (FIELD DECLARATIONS);
  1989.          SELECTOR: (FIELD DECLARATIONS);
  1990.          ...
  1991.      end;
  1992.  
  1993.    or, without a variant selector field,
  1994.  
  1995.      RECORD TYPE IDENTIFIER = record
  1996.        FIELD IDENTIFIER : TYPE DEFINITION
  1997.        ...
  1998.        FIELD IDENTIFIER : TYPE DEFINITION
  1999.        case VARIANT TYPE of
  2000.          SELECTOR: (FIELD DECLARATIONS);
  2001.          SELECTOR: (FIELD DECLARATIONS);
  2002.          ...
  2003.      end;
  2004.  
  2005. Description
  2006. -----------
  2007.  
  2008.    The reserved word `record' starts the definition of a new record
  2009. type.
  2010.  
  2011.    Records can be `packed' to save memory usage at the expense of speed.
  2012.  
  2013.    The variants of a variant record may - but are not required to -
  2014. share one location in memory (inside the record).
  2015.  
  2016.    Sometimes variant records are used to emulate type casting in
  2017. ISO-7185 Standard Pascal. This is in fact a violation of the standard
  2018. and not portable. There is intentionally _no_ possibility in ISO-7185
  2019. Standard Pascal to emulate type casting.
  2020.  
  2021. Conforming to
  2022. -------------
  2023.  
  2024.    The reserved word `record' and record types are defined in ISO-7185
  2025. Standard Pascal.
  2026.  
  2027.    According to ISO Pascal, the variant type must be an identifier.
  2028. GNU Pascal, like UCSD and Borland Pascal, also allows a subrange here.
  2029.  
  2030.    Subranges in the variant fields, e.g. `case Integer of 2 .. 5', are
  2031. a GPC extension.
  2032.  
  2033. Example
  2034. -------
  2035.  
  2036.      program RecordDemo;
  2037.      
  2038.      type
  2039.        FooPtr = ^Foo;
  2040.      
  2041.        Foo = record
  2042.          Bar: Integer;
  2043.          NextFoo: fooPtr;
  2044.          case Choice: 1 .. 3 of
  2045.            1: (a: Integer);  { These three choices may share }
  2046.            2: (b: Real);     { one location in memory. }
  2047.            3: (c: Char;
  2048.                d: Boolean);
  2049.        end;
  2050.      
  2051.        SmallFoo = packed record
  2052.          b: 0 .. 3;
  2053.          a: Integer (5);
  2054.          r: Boolean
  2055.        end;  { needs 1 byte }
  2056.      
  2057.      var
  2058.        f: Foo;
  2059.      
  2060.      begin
  2061.        f.b := 3.14;
  2062.        WriteLn (f.a)  { yields some strange number which is part of the   }
  2063.                       { internal representation of the real number `f.b'. }
  2064.      end.
  2065.  
  2066. See also
  2067. --------
  2068.  
  2069.    *Note packed::, *Note case Statement::
  2070.  
  2071. 
  2072. File: gpc.info,  Node: register,  Next: Release,  Prev: record,  Up: Reference
  2073.  
  2074. register
  2075. ========
  2076.  
  2077.    (Under construction.)
  2078.  
  2079. Synopsis
  2080. --------
  2081.  
  2082. Description
  2083. -----------
  2084.  
  2085. Conforming to
  2086. -------------
  2087.  
  2088. Example
  2089. -------
  2090.  
  2091. See also
  2092. --------
  2093.  
  2094. 
  2095. File: gpc.info,  Node: Release,  Next: Rename,  Prev: register,  Up: Reference
  2096.  
  2097. Release
  2098. =======
  2099.  
  2100.    (Under construction.)
  2101.  
  2102. Synopsis
  2103. --------
  2104.  
  2105.      procedure Release (P: Pointer);
  2106.  
  2107. Description
  2108. -----------
  2109.  
  2110. Conforming to
  2111. -------------
  2112.  
  2113. Example
  2114. -------
  2115.  
  2116. See also
  2117. --------
  2118.  
  2119. 
  2120. File: gpc.info,  Node: Rename,  Next: repeat,  Prev: Release,  Up: Reference
  2121.  
  2122. Rename
  2123. ======
  2124.  
  2125.    (Under construction.)
  2126.  
  2127. Synopsis
  2128. --------
  2129.  
  2130.      procedure Rename (var F: ANY FILE; NewName: String);
  2131.  
  2132. Description
  2133. -----------
  2134.  
  2135. Conforming to
  2136. -------------
  2137.  
  2138. Example
  2139. -------
  2140.  
  2141. See also
  2142. --------
  2143.  
  2144. 
  2145. File: gpc.info,  Node: repeat,  Next: Reset,  Prev: Rename,  Up: Reference
  2146.  
  2147. repeat
  2148. ======
  2149.  
  2150. Synopsis
  2151. --------
  2152.  
  2153.      repeat
  2154.        STATEMENT;
  2155.        ...
  2156.        STATEMENT;
  2157.      until BOOLEAN EXPRESSION;
  2158.  
  2159. Description
  2160. -----------
  2161.  
  2162.    The `repeat ... until' statement declares a loop.  For further
  2163. description see *Note repeat Statement::.
  2164.  
  2165. Conforming to
  2166. -------------
  2167.  
  2168.    `repeat' is defined in ISO-7185 Standard Pascal and supported by all
  2169. known Pascal variants.
  2170.  
  2171. Example
  2172. -------
  2173.  
  2174.      program RepeatDemo;
  2175.      var
  2176.        Number, Sum: Integer;
  2177.      begin
  2178.        WriteLn ('Black Jack for beginners.');
  2179.        WriteLn ('You can choose your cards yourself. :-)');
  2180.        Sum := 0;
  2181.        repeat
  2182.          Write ('Your card? ');
  2183.          ReadLn (Number);
  2184.          Inc (Sum, Number);
  2185.          WriteLn ('You have ', Sum, '.')
  2186.        until Sum >= 21;
  2187.        if Sum = 21 then
  2188.          WriteLn ('You win!')
  2189.        else
  2190.          WriteLn ('You lose.')
  2191.      end.
  2192.  
  2193. See also
  2194. --------
  2195.  
  2196.    *Note while Statement::, *Note for Statement::
  2197.  
  2198. 
  2199. File: gpc.info,  Node: Reset,  Next: resident,  Prev: repeat,  Up: Reference
  2200.  
  2201. Reset
  2202. =====
  2203.  
  2204.    (Under construction.)
  2205.  
  2206. Synopsis
  2207. --------
  2208.  
  2209.      procedure Reset (var F: ANY FILE; [FileName: String;]
  2210.                                          [BlockSize: Cardinal]);
  2211.  
  2212. Description
  2213. -----------
  2214.  
  2215.    `Reset' opens an existing file for reading. The file pointer is
  2216. positioned at the beginning of the file.
  2217.  
  2218.    Like `Rewrite', `Append' and `Extend' do, `Reset' accepts an
  2219. optional second and third parameter for the name of the file in the
  2220. filesystem and, for untyped files, the block size of the file. (For
  2221. details, see *Note Rewrite::.)
  2222.  
  2223. Conforming to
  2224. -------------
  2225.  
  2226.    `Reset' is defined in ISO-7185 Standard Pascal.  The `BlockSize'
  2227. parameter is a Borland Pascal extension.  The `FileName' parameter is a
  2228. GNU extension.
  2229.  
  2230. Example
  2231. -------
  2232.  
  2233.      program ResetDemo;
  2234.      var
  2235.        Sample: Text;
  2236.        s: String (42);
  2237.      begin
  2238.        Rewrite (Sample);  { Open an internal file for writing }
  2239.        WriteLn (Sample, 'Hello, World!');
  2240.        Reset (Sample);  { Open it again for reading }
  2241.        ReadLn (Sample, s);
  2242.        WriteLn (s);
  2243.        Close (Sample)
  2244.      end.
  2245.  
  2246. See also
  2247. --------
  2248.  
  2249.    *Note Assign::, *Note Rewrite::, *Note Append::, *Note Extend::.
  2250.  
  2251. 
  2252. File: gpc.info,  Node: resident,  Next: restricted,  Prev: Reset,  Up: Reference
  2253.  
  2254. resident
  2255. ========
  2256.  
  2257.    Not yet implemented.
  2258.  
  2259. Synopsis
  2260. --------
  2261.  
  2262. Description
  2263. -----------
  2264.  
  2265. Conforming to
  2266. -------------
  2267.  
  2268. Example
  2269. -------
  2270.  
  2271. See also
  2272. --------
  2273.  
  2274. 
  2275. File: gpc.info,  Node: restricted,  Next: Result,  Prev: resident,  Up: Reference
  2276.  
  2277. restricted
  2278. ==========
  2279.  
  2280.    (Under construction.)
  2281.  
  2282. Synopsis
  2283. --------
  2284.  
  2285. Description
  2286. -----------
  2287.  
  2288. Conforming to
  2289. -------------
  2290.  
  2291. Example
  2292. -------
  2293.  
  2294. See also
  2295. --------
  2296.  
  2297. 
  2298. File: gpc.info,  Node: Result,  Next: Return,  Prev: restricted,  Up: Reference
  2299.  
  2300. Result
  2301. ======
  2302.  
  2303.    (Under construction.)
  2304.  
  2305. Synopsis
  2306. --------
  2307.  
  2308. Description
  2309. -----------
  2310.  
  2311. Conforming to
  2312. -------------
  2313.  
  2314. Example
  2315. -------
  2316.  
  2317. See also
  2318. --------
  2319.  
  2320. 
  2321. File: gpc.info,  Node: Return,  Next: ReturnAddress,  Prev: Result,  Up: Reference
  2322.  
  2323. Return
  2324. ======
  2325.  
  2326.    (Under construction.)
  2327.  
  2328. Synopsis
  2329. --------
  2330.  
  2331. Description
  2332. -----------
  2333.  
  2334. Conforming to
  2335. -------------
  2336.  
  2337. Example
  2338. -------
  2339.  
  2340. See also
  2341. --------
  2342.  
  2343. 
  2344. File: gpc.info,  Node: ReturnAddress,  Next: Rewrite,  Prev: Return,  Up: Reference
  2345.  
  2346. ReturnAddress
  2347. =============
  2348.  
  2349.    (Under construction.)
  2350.  
  2351. Synopsis
  2352. --------
  2353.  
  2354. Description
  2355. -----------
  2356.  
  2357. Conforming to
  2358. -------------
  2359.  
  2360. Example
  2361. -------
  2362.  
  2363. See also
  2364. --------
  2365.  
  2366. 
  2367. File: gpc.info,  Node: Rewrite,  Next: RmDir,  Prev: ReturnAddress,  Up: Reference
  2368.  
  2369. Rewrite
  2370. =======
  2371.  
  2372.    (Under construction.)
  2373.  
  2374. Synopsis
  2375. --------
  2376.  
  2377.      procedure Rewrite (var F: ANY FILE; [FileName: String;]
  2378.                                          [BlockSize: Cardinal]);
  2379.  
  2380. Description
  2381. -----------
  2382.  
  2383.    `Rewrite' opens a file for writing. If the file does not exist, it
  2384. is created. The file pointer is positioned at the beginning of the file.
  2385.  
  2386.    Like `Reset', `Append' and `Extend' do, `Rewrite' accepts an
  2387. optional second and third parameter.
  2388.  
  2389.    The second parameter can specify the name of the file in the
  2390. filesystem. If it is omitted, the following alternative ways can be
  2391. used to specify the name. There are so many different ways in order to
  2392. be compatible to the idiosyncrasies of as many other Pascal compilers
  2393. as possible. (If you know about yet other ways, let us know...)
  2394.  
  2395.    * The `Assign' procedure (*note Assign::)
  2396.  
  2397.    * The `Bind' procedure (*note Bind::)
  2398.  
  2399.    The following ways are only available if the file is external, i.e.
  2400. a global variable which is mentioned in the program header.  Otherwise,
  2401. the file will be internal, i.e. get no name in the file system (it may
  2402. get a name temporarily, but will then be erased automatically again).
  2403. This is useful to store some data and read them back within a program
  2404. without the need for permanent storage.
  2405.  
  2406.    * A command-line parameter of the form `--gpc-rts=-nF:NAME' where F
  2407.      is the identifier of the file variable.
  2408.  
  2409.    * If the file was mentioned in the program header and the option
  2410.      `--transparent file names' (*note GPC Command Line Options::) was
  2411.      set, the file name will be identical to the identifier converted
  2412.      to lower-case.
  2413.  
  2414.    * Otherwise, the user will be prompted for a file name.
  2415.  
  2416.    The last optional parameter determines the block size of the file.
  2417. It is valid only for untyped files. Almost always, 1 is the most
  2418. reasonable value here. However, the existence of this parameter is a BP
  2419. compatibility feature, and in BP it defaults to 128 because of historic
  2420. misdesign. Therefore, GPC requires this parameter to be present. In
  2421. `--borland-pascal' mode, it makes it optional (like BP does), but warns
  2422. about the strange default if omitted.
  2423.  
  2424. Conforming to
  2425. -------------
  2426.  
  2427.    `Rewrite' is defined in ISO-7185 Standard Pascal.  The `BlockSize'
  2428. parameter is a Borland Pascal extension.  The `FileName' parameter is a
  2429. GNU extension.
  2430.  
  2431. Example
  2432. -------
  2433.  
  2434.      program RewriteDemo;
  2435.      var
  2436.        Sample: Text;
  2437.      begin
  2438.        Assign (Sample, 'sample.txt');
  2439.        Rewrite (Sample);
  2440.        WriteLn (Sample, 'Hello, World!');
  2441.        Close (Sample)
  2442.      end.
  2443.  
  2444. See also
  2445. --------
  2446.  
  2447.    *Note Assign::, *Note Reset::, *Note Append::, *Note Extend::, *Note
  2448. Update::.
  2449.  
  2450. 
  2451. File: gpc.info,  Node: RmDir,  Next: Root,  Prev: Rewrite,  Up: Reference
  2452.  
  2453. RmDir
  2454. =====
  2455.  
  2456. Synopsis
  2457. --------
  2458.  
  2459.      procedure RmDir (Directory: String);
  2460.  
  2461. Description
  2462. -----------
  2463.  
  2464.    `RmDir' removes the given DIRECTORY if its argument is a valid
  2465. parameter to the related operating system's function. Otherwise a
  2466. runtime error is caused.
  2467.  
  2468. Conforming to
  2469. -------------
  2470.  
  2471.    `RmDir' is a Borland Pascal extension.
  2472.  
  2473. Example
  2474. -------
  2475.  
  2476.      program RmDirDemo;
  2477.      var
  2478.        Foo: String (127);
  2479.      begin
  2480.        WriteLn ('Enter directory name to remove: ');
  2481.        ReadLn (Foo);
  2482.        {$i-}                     { Suppress exit on error }
  2483.        RmDir (Foo);
  2484.        if IOResult <> 0 then
  2485.          WriteLn ('Directory ', foo, ' could not be removed.')
  2486.        else
  2487.          WriteLn ('Okay.')
  2488.      end.
  2489.  
  2490. See also
  2491. --------
  2492.  
  2493.    *Note ChDir::, *Note MkDir::
  2494.  
  2495. 
  2496. File: gpc.info,  Node: Root,  Next: Round,  Prev: RmDir,  Up: Reference
  2497.  
  2498. Root
  2499. ====
  2500.  
  2501.    (Under construction.)
  2502.  
  2503. Synopsis
  2504. --------
  2505.  
  2506. Description
  2507. -----------
  2508.  
  2509. Conforming to
  2510. -------------
  2511.  
  2512. Example
  2513. -------
  2514.  
  2515. See also
  2516. --------
  2517.  
  2518. 
  2519. File: gpc.info,  Node: Round,  Next: RunError,  Prev: Root,  Up: Reference
  2520.  
  2521. Round
  2522. =====
  2523.  
  2524. Synopsis
  2525. --------
  2526.  
  2527.      function Round (x: Real): Integer;
  2528.  
  2529. Description
  2530. -----------
  2531.  
  2532.    `Round' returns the nearest integer to `x'. The result is of type
  2533. integer. In the case of equidistance, the result is machine-dependent
  2534. (or depends on the behaviour of the processor).
  2535.  
  2536. Conforming to
  2537. -------------
  2538.  
  2539.    `Round' is defined in ISO-7185 Standard Pascal and supported by all
  2540. known Pascal variants.
  2541.  
  2542. Example
  2543. -------
  2544.  
  2545.      program RoundDemo;
  2546.      var
  2547.        Foo: Real;
  2548.      begin
  2549.        foo := 9.876543;
  2550.        WriteLn (Round (Foo));  { Prints 10 }
  2551.        foo := 3.456789;
  2552.        WriteLn (Round (Foo))   { Prints 3 }
  2553.      end.
  2554.  
  2555. See also
  2556. --------
  2557.  
  2558.    *Note Round::
  2559.  
  2560. 
  2561. File: gpc.info,  Node: RunError,  Next: Seek,  Prev: Round,  Up: Reference
  2562.  
  2563. RunError
  2564. ========
  2565.  
  2566.    (Under construction.)
  2567.  
  2568. Synopsis
  2569. --------
  2570.  
  2571.      procedure RunError (ErrorCode: Integer);
  2572.  
  2573. Description
  2574. -----------
  2575.  
  2576. Conforming to
  2577. -------------
  2578.  
  2579. Example
  2580. -------
  2581.  
  2582. See also
  2583. --------
  2584.  
  2585. 
  2586. File: gpc.info,  Node: Seek,  Next: SeekRead,  Prev: RunError,  Up: Reference
  2587.  
  2588. Seek
  2589. ====
  2590.  
  2591.    (Under construction.)
  2592.  
  2593. Synopsis
  2594. --------
  2595.  
  2596.      procedure Seek (var F: TYPED FILE; NewPosition: Integer);
  2597.  
  2598. Description
  2599. -----------
  2600.  
  2601. Conforming to
  2602. -------------
  2603.  
  2604. Example
  2605. -------
  2606.  
  2607. See also
  2608. --------
  2609.  
  2610. 
  2611. File: gpc.info,  Node: SeekRead,  Next: SeekUpdate,  Prev: Seek,  Up: Reference
  2612.  
  2613. SeekRead
  2614. ========
  2615.  
  2616.    (Under construction.)
  2617.  
  2618. Synopsis
  2619. --------
  2620.  
  2621.      procedure SeekRead (var F: TYPED FILE; NewPosition: Integer);
  2622.  
  2623. Description
  2624. -----------
  2625.  
  2626. Conforming to
  2627. -------------
  2628.  
  2629. Example
  2630. -------
  2631.  
  2632. See also
  2633. --------
  2634.  
  2635. 
  2636. File: gpc.info,  Node: SeekUpdate,  Next: SeekWrite,  Prev: SeekRead,  Up: Reference
  2637.  
  2638. SeekUpdate
  2639. ==========
  2640.  
  2641.    (Under construction.)
  2642.  
  2643. Synopsis
  2644. --------
  2645.  
  2646.      procedure SeekUpdate (var F: TYPED FILE; NewPosition: Integer);
  2647.  
  2648. Description
  2649. -----------
  2650.  
  2651. Conforming to
  2652. -------------
  2653.  
  2654. Example
  2655. -------
  2656.  
  2657. See also
  2658. --------
  2659.  
  2660. 
  2661. File: gpc.info,  Node: SeekWrite,  Next: segment,  Prev: SeekUpdate,  Up: Reference
  2662.  
  2663. SeekWrite
  2664. =========
  2665.  
  2666.    (Under construction.)
  2667.  
  2668. Synopsis
  2669. --------
  2670.  
  2671.      procedure SeekWrite (var F: TYPED FILE; NewPosition: Integer);
  2672.  
  2673. Description
  2674. -----------
  2675.  
  2676. Conforming to
  2677. -------------
  2678.  
  2679. Example
  2680. -------
  2681.  
  2682. See also
  2683. --------
  2684.  
  2685. 
  2686. File: gpc.info,  Node: segment,  Next: Self,  Prev: SeekWrite,  Up: Reference
  2687.  
  2688. segment
  2689. =======
  2690.  
  2691.    Not yet implemented.
  2692.  
  2693. Synopsis
  2694. --------
  2695.  
  2696. Description
  2697. -----------
  2698.  
  2699. Conforming to
  2700. -------------
  2701.  
  2702. Example
  2703. -------
  2704.  
  2705. See also
  2706. --------
  2707.  
  2708. 
  2709. File: gpc.info,  Node: Self,  Next: set,  Prev: segment,  Up: Reference
  2710.  
  2711. Self
  2712. ====
  2713.  
  2714.    (Under construction.)
  2715.  
  2716. Synopsis
  2717. --------
  2718.  
  2719. Description
  2720. -----------
  2721.  
  2722. Conforming to
  2723. -------------
  2724.  
  2725. Example
  2726. -------
  2727.  
  2728. See also
  2729. --------
  2730.  
  2731. 
  2732. File: gpc.info,  Node: set,  Next: SetFileTime,  Prev: Self,  Up: Reference
  2733.  
  2734. set
  2735. ===
  2736.  
  2737.    (Under construction.)
  2738.  
  2739. Synopsis
  2740. --------
  2741.  
  2742.    In type definitions:
  2743.      set of TYPE  { built-in type class }
  2744.  
  2745. Description
  2746. -----------
  2747.  
  2748. Conforming to
  2749. -------------
  2750.  
  2751. Example
  2752. -------
  2753.  
  2754. See also
  2755. --------
  2756.  
  2757. 
  2758. File: gpc.info,  Node: SetFileTime,  Next: SetLength,  Prev: set,  Up: Reference
  2759.  
  2760. SetFileTime
  2761. ===========
  2762.  
  2763.      procedure SetFileTime (var f : ANY FILE;
  2764.                             AccessTime, ModificationTime : UnixTimeType);
  2765.  
  2766. Synopsis
  2767. --------
  2768.  
  2769. Description
  2770. -----------
  2771.  
  2772. Conforming to
  2773. -------------
  2774.  
  2775.    `SetFileTime' is a GNU extension.
  2776.  
  2777. Example
  2778. -------
  2779.  
  2780. See also
  2781. --------
  2782.  
  2783. 
  2784. File: gpc.info,  Node: SetLength,  Next: SetType,  Prev: SetFileTime,  Up: Reference
  2785.  
  2786. SetLength
  2787. =========
  2788.  
  2789. Synopsis
  2790. --------
  2791.  
  2792.      procedure SetLength (var S: String; NewLength: Integer);
  2793.  
  2794. Description
  2795. -----------
  2796.  
  2797.    `SetLength' explicitly assigns a new length `NewLength' to the
  2798. string parameter `S'.  The contents of the string is _not_ changed; if
  2799. the operation increases the length of the string, the characters
  2800. appended at the end are _undefined_.
  2801.  
  2802. Conforming to
  2803. -------------
  2804.  
  2805.    `SetLength' is a Borland Delphi 2.0 extension.
  2806.  
  2807. Example
  2808. -------
  2809.  
  2810.      program SetLengthDemo;
  2811.      
  2812.      var
  2813.        S : String (26);
  2814.      
  2815.      begin
  2816.        S := 'Hello, world!';
  2817.        SetLength (S, Length ('Hello'));
  2818.        WriteLn (S);                                           { 'Hello' }
  2819.      
  2820.        SetLength (S, 26);
  2821.        WriteLn (S);                     { 'Hello, world!(%$xy"!#&~+(/]' }
  2822.                                   { undefined characters ^^^^^^^^^^^^^^ }
  2823.      
  2824.        SetLength (S, 42);       { The overflow is *not* (yet) detected. }
  2825.        WriteLn (S);        { This might cause a runtime error or crash. }
  2826.      end.
  2827.  
  2828. See also
  2829. --------
  2830.  
  2831.    *Note Length::, *Note String::, *Note SetType::.
  2832.  
  2833. 
  2834. File: gpc.info,  Node: SetType,  Next: shl,  Prev: SetLength,  Up: Reference
  2835.  
  2836. SetType
  2837. =======
  2838.  
  2839. Synopsis
  2840. --------
  2841.  
  2842.      procedure SetType (var SomeObject; VMT: Pointer);
  2843.  
  2844. Description
  2845. -----------
  2846.  
  2847.    The procedure `SetType' explicitly assigns a value to the implicit
  2848. VMT field of an object.  This is normally done implicitly when a
  2849. constructor is called.
  2850.  
  2851.    You can use this to write a polymorphic I/O routine which reads an
  2852. object from a file.  In this case, you cannot reasonably use `New' to
  2853. allocate the storage, but you `GetMem' it and initialize the object
  2854. manually using `SetType' before calling the constructor explicitly.
  2855.  
  2856.    This is a dangerous feature which yields a warning unless `{$X+}' is
  2857. given.
  2858.  
  2859. Conforming to
  2860. -------------
  2861.  
  2862.    `SetType' is a GNU extension.
  2863.  
  2864. Example
  2865. -------
  2866.  
  2867.      program SetTypeDemo;
  2868.      
  2869.      type
  2870.        BasePtr = ^BaseObj;
  2871.      
  2872.        BaseObj = object
  2873.          constructor Load;
  2874.        end;
  2875.      
  2876.        ChildObj = object (BaseObj)
  2877.          constructor Load;
  2878.        end;
  2879.      
  2880.      constructor BaseObj.Load;
  2881.      begin
  2882.      end;
  2883.      
  2884.      constructor ChildObj.Load;
  2885.      begin
  2886.      end;
  2887.      
  2888.      {$X+}
  2889.      
  2890.      { This is somewhat fragmentary code. }
  2891.      function GetObject (var InputFile: File) = Result: BasePtr;
  2892.      const
  2893.        VMTTable: array [1 .. 2] of Pointer =
  2894.          (TypeOf (BaseObj), TypeOf (ChildObj));
  2895.      var
  2896.        Size: Cardinal;
  2897.        TypeID: Integer;
  2898.        VMT: Pointer;
  2899.      begin
  2900.        { Read the size of the object from some file and store it in `Size'. }
  2901.        BlockRead (InputFile, Size, SizeOf (Size));
  2902.      
  2903.        { Allocate memory for the object. }
  2904.        GetMem (Result, Size);
  2905.      
  2906.        { Read some ID from some file. }
  2907.        BlockRead (InputFile, TypeID, SizeOf (TypeID));
  2908.      
  2909.        { Look up the `VMT' from some table. }
  2910.        { Range checking wouldn't be a bad idea here... }
  2911.        VMT := VMTTable [TypeID];
  2912.      
  2913.        SetType (Result^, VMT);
  2914.      
  2915.        { Now the object is ready, and the constructor can be called. }
  2916.        { Look up the correct constructor from some table and call it. }
  2917.      end;
  2918.      
  2919.      begin
  2920.      end.
  2921.  
  2922. See also
  2923. --------
  2924.  
  2925.    *Note TypeOf::, *Note OOP::.
  2926.  
  2927. 
  2928. File: gpc.info,  Node: shl,  Next: ShortBool,  Prev: SetType,  Up: Reference
  2929.  
  2930. shl
  2931. ===
  2932.  
  2933. Synopsis
  2934. --------
  2935.  
  2936.      operator shl (operand1, operand2: INTEGER TYPE) = Result: INTEGER TYPE;
  2937.    or
  2938.      procedure shl (var operand1: INTEGER TYPE; operand2: INTEGER TYPE);
  2939.  
  2940. Description
  2941. -----------
  2942.  
  2943.    In GNU Pascal, `shl' has two built-in meanings:
  2944.  
  2945.   1. Bitwise shift left of an integer-type expression by another
  2946.      integer value.  The result is of the type of the first operand.
  2947.  
  2948.   2. Use as a "procedure":  `operand1' is shifted left by `operand2';
  2949.      the result is stored in `operand1'.
  2950.  
  2951.  
  2952. Conforming to
  2953. -------------
  2954.  
  2955.    `shl' is a Borland Pascal extension.
  2956.  
  2957.    Use of `shl' as a "procedure" is a GNU Pascal extension.
  2958.  
  2959. Example
  2960. -------
  2961.  
  2962.      program ShlDemo;
  2963.      var
  2964.        a: Integer;
  2965.      begin
  2966.        a := 1 shl 7;  { yields 128 = 2 pow 7 }
  2967.        shl (a, 4)  { same as `a := a shl 4' }
  2968.      end.
  2969.  
  2970. See also
  2971. --------
  2972.  
  2973.    *Note shr::, *Note Operators::.
  2974.  
  2975. 
  2976. File: gpc.info,  Node: ShortBool,  Next: ShortCard,  Prev: shl,  Up: Reference
  2977.  
  2978. ShortBool
  2979. =========
  2980.  
  2981.    (Under construction.)
  2982.  
  2983. Synopsis
  2984. --------
  2985.  
  2986.      type
  2987.        ShortBool = Boolean (BitSizeOf (ShortInt));
  2988.  
  2989. Description
  2990. -----------
  2991.  
  2992. Conforming to
  2993. -------------
  2994.  
  2995. Example
  2996. -------
  2997.  
  2998.      program ShortBoolDemo;
  2999.      var
  3000.        a: ShortBool;
  3001.      begin
  3002.        ShortInt (a) := 1;
  3003.        if a then WriteLn ('Ord (True) = 1')
  3004.      end.
  3005.  
  3006. See also
  3007. --------
  3008.  
  3009.